package util;

import java.util.Random;

public class Util {

    public static void swap(int[] arr, int i, int i2) {
        int tmp = arr[i];
        arr[i] = arr[i2];
        arr[i2] = tmp;
    }

    public static void print(int[] arr) {
        System.out.print("[ ");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
            if (i == arr.length - 1) {
                System.out.print(" ]");
                break;
            }
            System.out.print(", ");

        }
        System.out.println();
    }

    public static int[] generateArray(int len) {
        return generateArray(len, true);
    }

    public static int[] generateArray(int len, boolean flag) {
        Random random = new Random();

        int[] arr = new int[len];
        for (int i = 0; i < arr.length; i++) {
            if (flag) {
                arr[i] = random.nextInt() & Integer.MAX_VALUE % len;
            } else {
                arr[i] = random.nextInt() % len;
            }

        }
        return arr;
    }

}